home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Rechen3.cpp < prev    next >
C/C++ Source or Header  |  1998-12-11  |  2KB  |  61 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Rechen3.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. TForm1 *Form1;
  10. int Zahl1, Zahl2, Ergebnis;
  11.  
  12. //---------------------------------------------------------------------------
  13. __fastcall TForm1::TForm1(TComponent* Owner)
  14.     : TForm(Owner)
  15. {
  16. }
  17. //---------------------------------------------------------------------------
  18. void __fastcall TForm1::Label3Click(TObject *Sender)
  19. {
  20.   randomize ();
  21.   Zahl1 = random (100);
  22.   Zahl2 = random (100);
  23.   Label1->Caption = String (Zahl1);
  24.   Label2->Caption = String (Zahl2);
  25.   Label3->Caption = "WΣhle die Rechenart!";
  26. }
  27. //---------------------------------------------------------------------------
  28.  
  29. void __fastcall TForm1::Button1Click(TObject *Sender)
  30. {
  31.   Ergebnis = Zahl1 + Zahl2;
  32.   Label3->Caption = "Ergebnis der Addition:";
  33.   Label4->Caption = String(Ergebnis);
  34.   Panel1->Caption = Button1->Caption;
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TForm1::Button2Click(TObject *Sender)
  38. {
  39.   Ergebnis = Zahl1 - Zahl2;
  40.   Label3->Caption = "Ergebnis der Subtraktion:";
  41.   Label4->Caption = String(Ergebnis);
  42.   Panel1->Caption = Button2->Caption;
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TForm1::Button3Click(TObject *Sender)
  46. {
  47.   Ergebnis = Zahl1 * Zahl2;
  48.   Label3->Caption = "Ergebnis der Multiplikation:";
  49.   Label4->Caption = String(Ergebnis);
  50.   Panel1->Caption = Button3->Caption;
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TForm1::Button4Click(TObject *Sender)
  54. {
  55.   Ergebnis = Zahl1 / Zahl2;
  56.   Label3->Caption = "Ergebnis der Division:";
  57.   Label4->Caption = String(Ergebnis);
  58.   Panel1->Caption = Button4->Caption;
  59. }
  60. //---------------------------------------------------------------------------
  61.